﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GenerateDiagram
{
    public class ForeignKey:AbstractBase
    {
        public string MemberName{get; set;}
        public string OtherTable;
        public string ThisTable;
        public RenderOption RenderOption { get; set; }
        public bool CanBeNull = true;
        public ForeignKey BackReference;

        public string ToForeignKeyProperty(Common.Version version)
        {
            switch (version)
            {
                case Common.Version.Net2_0: 
                case Common.Version.Net3_0:
                     string property = this.MemberName.Substring(0,1).ToLower()+ this.MemberName.Substring(1);
                    string proInfo = "private " + this.OtherTable + " " + property + ";";
                    proInfo += "\r";
                    proInfo += "\tpublic " + this.OtherTable + " " + this.MemberName;
                    proInfo += "\r\n\t{\r\n";
                    proInfo += "\t\tget { return " + property + "; }";
                    proInfo += "\r\n\t\tset { " +property+" =  value; }";
                    proInfo += "\r\n\t}\r\n";
                    return proInfo;
                case Common.Version.Net3_5:
                case Common.Version.Net4_0:
                    return "public "+ this.OtherTable+ " " + this.MemberName + " { get; set; }";
            }
            return "";
        }
    }
}
